<div style="display:flex;margin-bottom:10px;margin-left:10px;margin-right:10px;">
  <div style="padding-top: 10px;">
    <mat-icon style="padding-top: 3px;">build</mat-icon>
    <h4 style="display: inline;position: relative;top: -5px;">
      <ng-container i18n>
        Working Changes
      </ng-container>
    </h4>
  </div>
  <div style="flex: 1 1 auto"></div>
  <div>
    <app-controls (refresh)="refresh()" [showSpinner]="loading" [showRefresh]="true"></app-controls>
  </div>
</div>

<div style="display: flex; flex-direction: column;margin-right:10px;margin-left:10px;">
  <mat-table #table [dataSource]="datasource">

    <ng-container matColumnDef="actions">
      <mat-header-cell *matHeaderCellDef [ngClass]="'actionWidth'">
        <ng-container i18n>
          &nbsp;
        </ng-container>
      </mat-header-cell>
      <mat-cell *matCellDef="let row" [ngClass]="'actionWidth'">
        <button mat-icon-button [matMenuTriggerFor]="changeMenu" (click)="selectedItem = row">
          <mat-icon>menu</mat-icon>
        </button>
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="filename">
      <mat-header-cell *matHeaderCellDef [ngClass]="'filenameWidth'">
        <ng-container i18n>
          File
        </ng-container>
      </mat-header-cell>
      <mat-cell *matCellDef="let row" [ngClass]="'filenameWidth'">
        {{ row.fileName }}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="serviceName">
      <mat-header-cell *matHeaderCellDef [ngClass]="'serviceNameWidth'">
        <ng-container i18n>
          Service Name
        </ng-container>
      </mat-header-cell>
      <mat-cell *matCellDef="let row" [ngClass]="'serviceNameWidth'">
        {{ row.serviceName }}
      </mat-cell>
    </ng-container>

    <ng-container matColumnDef="changeType">
      <mat-header-cell *matHeaderCellDef [ngClass]="'changeTypeWidth'">
        <ng-container i18n>
          Change Type
        </ng-container>
      </mat-header-cell>
      <mat-cell *matCellDef="let row" [ngClass]="'changeTypeWidth'">
        {{ row.changeType }}
      </mat-cell>
    </ng-container>

    <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
    <mat-row *matRowDef="let row; columns: displayedColumns;" [ngClass]="row.changeType"></mat-row>

  </mat-table>
  <app-paginator></app-paginator>
</div>

<mat-menu #changeMenu>
  <button mat-menu-item (click)="viewDiff()" *ngIf="selectedItem && selectedItem.changeType === 'MODIFY'">
    <mat-icon>compare_arrows</mat-icon>
    <ng-container i18n>View Diff</ng-container>
  </button>
  <button mat-menu-item (click)="viewJSON()">
    <mat-icon>code</mat-icon>
    <ng-container>JSON</ng-container>
  </button>
  <button mat-menu-item (click)="openModalRevert()">
    <mat-icon>undo</mat-icon>
    <ng-container>Revert</ng-container>
  </button>
</mat-menu>
